﻿

//初始化列表信息
function LoadFlow(queryData) {
    $('#flowdlg').dialog('open').dialog('setTitle', '选择流程');
    $('#flowlist').datagrid({
        //title: '工作流程设置',
        idField: 'FlowConfigID',
        fitColumns: 'true',
        autoRowHeight: true,
        nowrap: true,
        striped: true,
        singleSelect: true,
        pagination: true,
        url: '/WFFlowConfig/GetList',
        queryParams: queryData,
        columns: [[
			{ field: 'ck', checkbox: true },
			{ field: 'FlowConfigID', title: 'ID', hidden: true },
			{ field: 'FlowConfigName', title: '流程名称', width: 180 },
			{ field: 'FlowKindName', title: '流程分类', width: 180 },
			{ field: 'CreateBy', title: '创建人', width: 180, hidden: true },
            {
                field: 'CreateTime', title: '创建时间', width: 180,
                formatter: function (value, row, index) {
                    return formatDate(value, "yyyy-MM-dd HH:mm:ss");
                }, hidden: true
            },
			{ field: 'UpdateBy', title: '修改人', width: 180, hidden: true },
            {
                field: 'UpdateTime', title: '修改时间', width: 180,
                formatter: function (value, row, index) {
                    return formatDate(value, "yyyy-MM-dd HH:mm:ss");
                }, hidden: true
            }

        ]],
    });
}

//根据类型，流程名称查询流程
function SearchFlow() {
    var flowKind = $('#cmb_FlowKind').combobox('getValue');
    var configName = $('#txt_ConfigName').val();

    if (flowKind == '请选择类型') {
        flowKind = '';
    }
    if (configName == '流程名称') {
        configName = '';
    }
    var querData = {
        j_flowKind: flowKind,
        j_configName: configName
    };

    LoadFlow(querData);
}

//选择流程
function SelectFlow() {
    var rows = $("#flowlist").datagrid("getSelections");
    if (rows.length == 1) {
        var configID = rows[0].FlowConfigID;
        var configName = rows[0].FlowConfigName;
        $("#hi_FlowConfigID").val(configID);
        $("#txt_FlowConfigName").val(configName);
        $('#com_ApprovalUserID').combobox('reload', '/WFFlowConfig/GetApprovalUsers?flowConfigID=' + configID + '&stepLevel=1')
        $('#flowdlg').dialog('close');
    }
    else {
        $.messager.alert("友情提示", "请选择流程");
    }
}